package com.jilefojing.session.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jilefojing.beans.enums.PlatformEnum;
import com.jilefojing.context.beans.vo.UserToken;
import com.jilefojing.session.service.ILogoutService;
import com.jilefojing.session.service.IUserSessionService;
import com.jilefojing.util.Detect;

/**
 * @author jgshun
 * @date 2016-4-14 上午9:58:30
 * @version 1.0
 */
@Service
public class LogoutService implements ILogoutService {
	@Autowired
	private IUserSessionService userSessionService;
	private static final Logger _LOGGER = LoggerFactory.getLogger(LogoutService.class);

	@Override
	public void logout(UserToken userToken, PlatformEnum platform) {
		if (Detect.notEmpty(userToken.getUid())) {
			userSessionService.deleteByUid(userToken.getUid());
		}

		// if (platform == PlatformEnum.PC || platform == PlatformEnum.WAP) {
		// HttpServletRequest request = ((ServletRequestAttributes)
		// RequestContextHolder.getRequestAttributes()).getRequest();
		// HttpServletResponse response = ((ServletRequestAttributes)
		// RequestContextHolder.getRequestAttributes()).getResponse();
		// if (response == null) {
		// response = (HttpServletResponse)
		// request.getAttribute(Constants._WEB_LOCAL_RESPONSE);
		// }
		// UserTokenUtil.clearUserTokenFromCookie(request, response);
		// }

	}

}
